﻿Imports Lucene.Net.Analysis

Namespace Aricie.DNN.Modules.LuceneSearch.Business
    Public Class LuceneNet40Provider
        Inherits Aricie.DNN.Modules.LuceneSearch.Business.SpecificVersionLuceneProvider

        Public Overrides Sub ExtractNativeTerm(objQuery As Lucene.Net.Search.Query, extractItem As HashSet(Of Lucene.Net.Index.Term))
            objQuery.ExtractTerms(extractItem)
        End Sub

        Public Overrides Function GetSetBaseFieldSelectorFromHasSet(fieldsNeeded As HashSet(Of String)) As Lucene.Net.Documents.SetBasedFieldSelector
            Return New Global.Lucene.Net.Documents.SetBasedFieldSelector(Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet(Of String)(fieldsNeeded), Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet(Of String))
        End Function

        Public Overrides Function MakeStopSet(stopWords As String()) As HashSet(Of String)
            Return New HashSet(Of String)(Lucene.Net.Analysis.StopFilter.MakeStopSet(stopWords))
        End Function

        Public Overrides Function GetStopFilter(ByVal enablePositionIncrement As Boolean, ByVal stream As TokenStream, ByVal stopSet As HashSet(Of String), ByVal ignoreCase As Boolean) As StopFilter
            Return New StopFilter(enablePositionIncrement, stream, Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet(Of String)(stopSet), ignoreCase)
        End Function


        Public Overrides Function CreateHashSet(Of T)() As HashSet(Of T)
            Return DirectCast(Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet(Of T)(), HashSet(Of T))
        End Function
        Public Overrides Function CreateHashSet(Of T)(ByVal items As IEnumerable(Of T)) As HashSet(Of T)
            Return DirectCast(Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet(Of T)(items), HashSet(Of T))
        End Function


        Public Overrides Function GetStandardAnalyzer() As Lucene.Net.Analysis.Standard.StandardAnalyzer
            Dim toReturn As Lucene.Net.Analysis.Standard.StandardAnalyzer
            toReturn = New Lucene.Net.Analysis.Standard.StandardAnalyzer(Aricie.DNN.Modules.LuceneSearch.Common.Constants.LuceneCurrentVersion, Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet(Of String))
            Return toReturn
        End Function
    End Class
End Namespace
